﻿using System;

namespace ConsoleInput
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = GetInt("x");
            int y = GetInt("y");

            Console.WriteLine("x + y = " + (x + y));
            

            Console.ReadKey();
        }

        static int GetInt(string name)
        {
            int a;

            bool isParsed;

            do
            {
                Console.Write(name + " = ");
                isParsed = int.TryParse(Console.ReadLine(), out a);

                if (!isParsed)
                {
                    Console.WriteLine("Parse error. Please try again.");
                }
            }
            while (!isParsed);

            return a;
        }

        static double GetDouble(string name)
        {
            double a;

            bool isParsed;

            do
            {
                Console.Write(name + " = ");
                isParsed = double.TryParse(Console.ReadLine(), out a);

                if (!isParsed)
                {
                    Console.WriteLine("Parse error. Please try again.");
                }
            }
            while (!isParsed);

            return a;
        }
    }

    
}
